<?php

require_once('post_controller.php');
require_once('category_controller.php');
require_once('../includes/smarty/libs/Smarty.class.php');
require_once('../const.php');

// TODO: provide a better way of managing when errors should be cleared
Post::clearErrors(); 

$post = new PostController();
$category = new CategoryController();

$smarty = new Smarty();

$smarty->assign("title", BLOG_NAME . ": Home");
$smarty->assign("username", $_SESSION['username']);
$smarty->assign("loggedIn", $session->checkLogin());
$smarty->assign("numberOfPosts", $post->getNumberOfPosts());
$smarty->assign("posts", $post->getAllPosts());
$smarty->assign("categories", $category->getAllCategories());
$smarty->display('index.tpl');

?>